package ModLayer;
import java.util.ArrayList;
import java.io.*;

/**
 * Write a description of class PersonCon here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class PersonCon
{
    private static PersonCon instance;
    private ArrayList<PersonInformations> personList;
    private BankFileHandler fileHandler;
    
    private PersonCon()
    {
        personList = new ArrayList<PersonInformations>();
        fileHandler = new BankFileHandler("Person_list_data");
    }
    
    public static PersonCon getInstance()
    {
        if(instance == null)
            instance = new PersonCon();
        return instance;
    }
    
    public void add(PersonInformations person)
    {
        personList.add(person);
    }
    
    public ArrayList<PersonInformations> getPersonList()
    {
        return personList;
    }
    
    public void saveToFile() throws IOException
    {
        fileHandler.saveToFile(personList);
    }
    
    public void loadFromFile() throws IOException, ClassNotFoundException
    {
        personList = fileHandler.readFromFile();
    }
}